<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let input = `600 200 100 4 20
7`

let list_sp = input.split('\n')
let [H, N_arr] = [
  parseInt(list_sp[1]),
  list_sp[0].split(' ').map(v => {
    return parseInt(v)
  }),
]
let N_max = Math.max(...N_arr)

if (H < N_arr.length) {
  console.log(0)
} else if (H === N_arr.length) {
  console.log(N_max)
} else {
  let M = H - N_arr.length //每个桃树分配1个小时，多的时间记为M
  let N_newarr = N_arr.sort((a, b) => a - b) //给桃树从小到大排序
  let K = N_newarr[N_arr.length - 1 - M]

  if (N_max < K * 2) {
    //理想速度 最大桃树小于该值的二倍
    console.log(K)
  } else {
    //从大到小遍历桃树，每棵树有N个桃子，除以速度K，减去原本就分配的时间1，速度要大于理想速度，所以从N_arr.length - 1 - M+1开始，
    for (let i = N_arr.length - 1 - M + 1; i > 0; i--) {
      let tag = M
      K = N_arr[i] //假设吃的速度
      for (let j = N_arr.length - 1; j > i; j--) {
        tag -= Math.ceil(N_arr[j] / K) - 1 //从大到小每个桃树要吃的次数（时间）
      }
      if (tag == 0) {
        console.log(K)
        break
      }
      if (tag < 0) {
        console.log(0)
        break
      }
    }
  }
}
    </script>
</body>
</html>